﻿<?php

$con = mysql_connect("localhost","root","123") or die  ('Error connecting to mysql');
mysql_select_db("download.com.vn");
@mysql_query("SET NAMES 'UTF8'");

/*

DROP TABLE IF EXISTS `ht4u_docx`;
CREATE TABLE `ht4u_docx` (
  `id` int(7) NOT NULL auto_increment,
  `idbv` int(10),
  `tenbv` longtext,
  `linkbv` longtext,
  `tag` longtext,
  `thumb` longtext,
  `buy` int(2) default '0',
  `linkdown` VARCHAR(1024) NOT NULL DEFAULT '0' ,
  `tthai` int(2) default '0',
  `idcate` int(5) default '0',
  `linkmf` longtext,
  `name_file` longtext,
  `size` varchar(20) default '-1',
  `ndbv` longtext,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

//156,322
http://localhost/get-bv/get_code_docx.php?rs=7
http://localhost:9099/get-bv/idoc.vn/get_code_idoc.vn.php?rs=2&page=8541

//doc,docx,pdf,ppt,pptx


page: 10471
*/


//print_r($list);
$time_add = time();
$tcount = 1;
$end_time = 1;
while(1)
{
	$result = mysql_query("SELECT count(*) as num FROM `getsoft` where GET_STATUS = 1");
	$row = mysql_fetch_array($result);

	$end_time = time() - $time_add;
	$time_add = time();
	$total = $tcount - $row['num'];
	$totaltime = ($row['num']/$total)*$end_time;
	$totaltime = (int)$totaltime;
	$totaltime = date("H:i:s",$totaltime);
	$tcount = $row['num'];
	//echo "\rRunning ".$row['num']."...";
	
	echo "\rTime: ".$totaltime.", Total: ".$row['num'];
	
	if(!$row || $row['num'] <=0){
		echo "\rShutdown ...";
		//echo exec('cmd.exe /K shutdown /f /t 50 /s');
		//return '';
	}
	else {
	//echo "\rRunning ".$row['num']."...";
	
	}
	
	sleep(5);
}

mysql_close($con);


?>